/***************************************************************/
//gameManager takes care of the turns, map, what's displaying, the menus, etc.
// Tyler Wozniak & Andrew Hall
/***************************************************************/


#ifndef GAME_MANAGER
#define GAME_MANAGER
#include "imports.h"
#include "Unit.h"
#include "Player.h"
#include "Map.h"
#include "Display.h"

class GameManager
{
friend class Display;
private:
	bool gameOver;			//Boolean representing that the game is over
	bool gameWon;			//Boolean representing if you won the game
	Display* mainDisp;		//Pointer to the display
	Map* currMap;			//Pointer to the map
	Player* currentPlayer;	//Pointer to the player
	Stack<Map> prevFloors;	//Stack of floors - UNUSED, but would use for more floors in future versions
	gameState curState;		//Current state of the game ENUM
	static const int AGGRO_RANGE = 10;	//Range at which creatures chase the hero
	int curTurn;			//The current turn
public:
	GameManager(void);
	Player* getCurPlayer();
	void initialize(void);
	void playGame();
	~GameManager(void);
	bool getNextInput(char& nextIn);
	void evaluateInput(char inp);
	Map* getCurrentMap();
	Display* getCurrentDisplay();
	void setCurState(string newState);
	vector<char> getValidIns();
	void processGameTurn(char in);
};


#pragma region For_Each Functors
//Another foreach helper Functor, for taking strings and adding them to an STL queue
struct stringToQueue
{
	queue<string>* myQRef;
	stringToQueue(queue<string>& myQ)
	{
		myQRef = &myQ;
	}
	void operator()(string in)
	{
		myQRef->push(in);
	}
};

//Helper functor for for_each
//Only way to do this without using Pointer-to-Member-Functions...
struct dispFctor
{
	Display* disRef;
	dispFctor(Display* ref)
	{
		disRef = ref;
	}
	void operator()(pair<char,int> ind)
	{
		disRef->displayCharColors[ind.first] = Display::DARKGREY;
	}
};

//ForEach helper functor for printing strings in an STL container
struct printStrings
{
	void operator()(string out)
	{
		cout << out << endl;
	}
};

//Yet another helper functor for an algorithm
//Takes a string at defintion, then can search through
//strings in a container for that string
struct findStringPart
{
	string finder;
	findStringPart(string find)
	{
		finder = find;
	}
	bool operator()(string check)
	{
		return (check.find(finder) != string::npos);
	}
};
#pragma endregion

#endif